//
//  LauchLoadingViewController.m
//  CarTown
//
//  Created by xionghao on 15/9/30.
//  Copyright © 2015年 熊浩. All rights reserved.
//

#import "LauchLoadingViewController.h"
#import "NetWorkUtils.h"
#import "PostUitls.h"
#import "CarSourceTypeUtils.h"
#import "CatTypeUtils.h"
#import "CatMode.h"
#import "AddressUtils.h"
#import "KuWeiUtils.h"
#import "AreaUtils.h"
#import "ProcessUtils.h"
#import "BrandUtils.h"
#import "LoginRootViewController.h"
#import "RootTabViewController.h"

@interface LauchLoadingViewController ()

@end

@implementation LauchLoadingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
     BOOL islogin=[XHUserDeflaut boolForKey:LOGINSTATE];
    [AddressUtils getAddress:^(bool isok) {
        [CatTypeUtils getCatType:^(bool isok) {
            [CarSourceTypeUtils getCarSourceType:^(bool isok) {
                
                [KuWeiUtils getKuWei:^(bool isok) {
                    [AreaUtils getArea:^(bool isok) {
                        [BrandUtils getBrand:^(bool isok) {
                            [ProcessUtils getProcess:^(bool isok) {
                                                                LoginRootViewController *lgvc=[XHMianStory instantiateViewControllerWithIdentifier:@"lognav"];
                                                              [UIApplication sharedApplication].keyWindow. rootViewController=lgvc;
                                
                                                                if ([lgvc respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
                                                                    lgvc.interactivePopGestureRecognizer.enabled = NO;
                                                                }
                                                                if (islogin) {
                                                                    
                                                                    [self pushtTOTab:lgvc];
//                                                                    [lgvc pushViewController:[XHMianStory instantiateViewControllerWithIdentifier:@"tabroot"] animated:NO];
                                                                }
                                
                            }];
                        }];
                    }];
                }];
                
            }];
        }];
    }];

    
    // Do any additional setup after loading the view from its nib.
}

-(void)pushtTOTab:(LoginRootViewController *)vc{
    RootTabViewController *rootvc=[[RootTabViewController alloc]init];
    
    [vc pushViewController:rootvc animated:NO];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
